package org.goj.user.service.impl;

import cn.hutool.core.lang.Assert;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.goj.common.entity.user.TeamUser;
import org.goj.user.mapper.TeamUserMapper;
import org.goj.user.service.TeamUserService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 团队用户关联 服务实现类
 * </p>
 *
 * @author CK
 * @since 2021-05-05
 */
@Service
public class TeamUserServiceImpl extends ServiceImpl<TeamUserMapper, TeamUser> implements TeamUserService {

    @Override
    public boolean listValidate(Integer teamId, String email) {
        QueryWrapper<TeamUser> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("team_id", teamId).eq("email", email);
        List<TeamUser> list = super.list(queryWrapper);
        Assert.notNull(list, "出错了");
        return list.size() == 1;
    }
}
